﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Prueba.aspx.cs" Inherits="TestNutricionalWeb.Prueba" %>

<!DOCTYPE html>

<html lang="es-ar">

<head runat="server">
    <link href="Estilos.css" rel="stylesheet" type="text/css" />
    <link href="jquery.loadmask.css" rel="stylesheet" type="text/css" />   
    <link href="jquery-ui.css" rel="stylesheet" type="text/css" />  
    <link href="ui.selectmenu.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="Resources/jquery-1.7.2.min.js"></script>   
    <script type="text/javascript" src="Resources/jquery-ui-1.8.20.custom.min.js"></script>
    <script type="text/javascript" src="Resources/jquery.loadmask.min.js"></script>
    <script type="text/javascript" src="Resources/jquery.progressbar.min.js"></script>
    <script type="text/javascript" src="Resources/jquery.filedownload.js"></script>    
    <script type="text/javascript" src="ui.selectmenu.js"></script>
    <script type="text/javascript">
        $(function () {
            $(document).on("click", "a.fileDownloadCustomRichExperience", function () {

                var $preparingFileModal = $("#preparing-file-modal");

                $preparingFileModal.dialog({ modal: true });

                $.fileDownload($(this).attr('href'), {
                    successCallback: function (url) {

                        $preparingFileModal.dialog('close');
                    },
                    failCallback: function (responseHtml, url) {

                        $preparingFileModal.dialog('close');
                        $("#error-modal").dialog({ modal: true });
                    }
                });
                return false; //this is critical to stop the click event which will trigger a normal file download!
            });
        });
    </script>
</head>
<body>
    <a class="fileDownloadCustomRichExperience" href="/DEscarga.aspx">Bajaaaaa!</a>
    <div id="preparing-file-modal" title="Preparando PDF..." style="display: none;">
        Estamos preparando el resultado del Test ...
        <div class="ui-progressbar-value ui-corner-left ui-corner-right" style="width: 100%; height:22px; margin-top: 20px;"></div>
    </div>
    <div id="error-modal" title="Error" style="display: none;">
        Hubo un problema al generar el resultado. Por favor, inténtelo más tarde.
    </div>
</body>
</html>
